package com.jsyh.maidu.presenter;

import android.content.Context;

import com.jsyh.maidu.config.ConfigValue;
import com.jsyh.maidu.http.BaseDelegate;
import com.jsyh.maidu.http.OkHttpClientManager;
import com.jsyh.maidu.model.GoodsAttrModel;
import com.jsyh.maidu.views.GoodsAttrView;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by ZHY_9 on 2017/7/20.
 */

public class ParamPresenter extends BasePresenter {

    GoodsAttrView view;

    public ParamPresenter(GoodsAttrView view) {
        this.view = view;
    }

    public void getGoodsAttr(Context context, String goods_id, String attr_value_id, String num) {
        Map<String, String> param = new HashMap<>();
        param.put("goods_id", goods_id);
        param.put("attr_value_id", attr_value_id);
        param.put("num", num);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "goods/get_goods_attr", param, new BaseDelegate.ResultCallback<GoodsAttrModel>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {

            }

            @Override
            public void onResponse(GoodsAttrModel response, Object tag) {
                view.getGoodsAtrr(response);
            }
        });
    }
}
